#include <iostream>
#include <algorithm>
using namespace std;

const int N = 110;
int a[N];
int n, T;

int main()
{
	cin >> T;
	while(T--)
	{
		cin >> n;
		
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + 1 + n);
		cout << a[n] - a[1] << endl;
	}
	return 0;
 } 
